﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DAPNet
{
    public class SimpleGate : IOfflineEffect
    {
        private double treshold;


        public SimpleGate(double treshold)
        {
            this.treshold = treshold;
        }

        public double Treshold
        {
            get 
            { 
                return treshold; 
            }
            set 
            { 
                treshold = value; 
            }
        }

        public void Process(SampleCollection samples)
        {
            double absTresholdValue = Math.Abs(treshold);
            for (int i = 0; i < samples.Count; i++)
            {
                double absValue = Math.Abs(samples[i].Value);
                if (absValue < absTresholdValue)
                {
                    samples[i].SetTrimmedValue(Sample.BaseValue);
                }
            }
        }
    }
}
